package com.boang.common;

import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String msg;
    private T data;
    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public Result(int code) {
        this.code = code;
    }
    public Result() {
        
    }
    public static <T> Result<T> success() {
        return new Result<T>(200, "success");
    }
    public static <T> Result<T> success(T data) {
        return new Result<T>(200, "success", data);
    }
    public static <T> Result<T> success(String msg) {
        return new Result<T>(200, msg);
    }
    public static <T> Result<T> success(String msg, T data) {
        return new Result<T>(200, msg, data);
    }
    public static <T> Result<T> error() {
        return new Result<T>(500, "error");
    }
}
